package cave.ui;

import java.util.ArrayList;

import cave.game.InputEvent;
import cave.renderer.RenderList;

public class UiContainer {
	
	public ArrayList<StaticUiItem> allItems;
	public ArrayList<DynamicUiItem> dymanicItems;
	
	public UiContainer() {
		allItems = new ArrayList<StaticUiItem>();
		dymanicItems = new ArrayList<DynamicUiItem>();
	}
	
	/**
	 * Updates all added DynamicUiItems in the same order as they were added
	 */
	public void update(float dt, ArrayList<InputEvent> events) {
		for (int i = 0; i < dymanicItems.size(); i++) {
			dymanicItems.get(i).update(dt, events);
		}
	}
	
	public void draw(RenderList renderList) {
		for (int i = 0; i < allItems.size(); i++) {
			allItems.get(i).draw(renderList);
		}
	}
	
	public void add(DynamicUiItem item) {
		dymanicItems.add(item);
		allItems.add(item);
	}
	
	public void add(StaticUiItem item) {
		allItems.add(item);
	}

	public void destroy() {
		for (int i = 0; i < allItems.size(); i++) {
			allItems.get(i).destroy();
		}
	}

}
